package com.jeff.tianti.controller;

import com.jeff.tianti.cms.entity.Consult;
import com.jeff.tianti.cms.entity.ConsultCategory;
import com.jeff.tianti.cms.service.ConsultCategoryService;
import com.jeff.tianti.cms.service.ConsultService;
import com.jeff.tianti.common.dto.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@CrossOrigin(maxAge = 3600)
@RestController
@RequestMapping("/consultCategory")//知识产权
public class ConsultCategoryController {


    @Autowired
    private ConsultCategoryService consultCategoryService;
    @Autowired
    private ConsultService consultService;

    /**
     * @Ceator:liuYI
     * @Describe:知识产权模块数据列表
     */
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public AjaxResult consultCategoryList() {
        Map allNoDel = consultCategoryService.findAllNoDel();
        return AjaxResult.setSuccessData(allNoDel);
    }

    /**
     * @Ceator:liuYI
     * @Describe:获取知识产权咨询类型列表
     */
    @RequestMapping(value = "/findCateAttr", method = RequestMethod.GET)
    public AjaxResult findConsultCategoryById(@RequestParam("id") String id) {
        List<ConsultCategory> categorys = consultCategoryService.findConsultCategoryById(id);
        return AjaxResult.setSuccessData(categorys);
    }

    /**
     * @Ceator:liuYI
     * @Describe:知识产权用户咨询数据录入
     */
    @RequestMapping(value = "/saveConsult", method = RequestMethod.POST)
    public AjaxResult saveConsult(@RequestBody Consult consult) {
        consult.setState(Consult.CONSULT_STATE_ING);
        consultService.save(consult);
        return AjaxResult.setSuccessData(null);
    }
}
